package com.lin.entity.dto;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.lin.exception.BookFieldInvalidException;
import com.lin.exception.BookIdInvalidException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateBookDTO {

    private Integer id;             // id

    private String title;           // 标题

    private String author;          // 作者


    public boolean isBlank() {
        if (id == null || id <= 0)
            throw new BookIdInvalidException("图书ID无效");
        if (StringUtils.isBlank(title))
            throw new BookFieldInvalidException("图书标题不能为空");
        if (StringUtils.isBlank(author))
            throw new BookFieldInvalidException("图书作者不能为空");
        return true;
    }
}
